<?xml version="1.0" encoding="ISO-8859-1" ?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions"
	xmlns:fmt="http://java.sun.com/jsp/jstl/fmt" version="2.0">
	<jsp:directive.page contentType="text/html; charset=ISO-8859-1"
		pageEncoding="ISO-8859-1" session="false" />
	<jsp:output doctype-root-element="html"
		doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
		doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
		omit-xml-declaration="true" />
	<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Product's Details</title>
	<link href="/static/base.css" rel="stylesheet" type="text/css"></link>
</head>
<body>

<script src="/js/jquery-1.7.2.min.js">""</script>
<script src="/js/browse.buy.js">""</script>

	<c:choose>
		<c:when test="${userSession.type == 'User'}">
			<jsp:include page="/WEB-INF/jsp/page.header.jsp"></jsp:include>
		</c:when>
		<c:otherwise>
			<jsp:include page="/WEB-INF/jsp/admin/header.jsp"></jsp:include>
		</c:otherwise>
	</c:choose>
	<div style="text-align: left">
		<h1>Product's Details</h1>
		<table border="0" cellpadding="0" cellspacing="0">

			<c:if test="${userSession.type == 'User'}">
				<tr>
					<td colspan="3"><a
						href="/service/product/view?id=${product.productId}">Edit</a></td>
				</tr>
			</c:if>

			<tr>
				<td colspan="3">&#160;</td>
			</tr>
			<tr>
				<td align="left">Category</td>
				<td>&#160;:&#160;</td>
				<td>${fn:escapeXml(product.category)}</td>
			</tr>
			<tr>
				<td align="left">Product's Name</td>
				<td>&#160;:&#160;</td>
				<td>
				${fn:escapeXml(product.name)} 
				<button onclick='browse.buy(${product.key.id})'>buy</button>
				</td>
			</tr>
			<tr>
				<td align="left">Product's Picture</td>
				<td>&#160;:&#160;</td>
				<td>${product.picture}</td>
			</tr>
			<tr>
				<td align="left">Product's Price</td>
				<td>&#160;:&#160;</td>
				<td><fmt:formatNumber type="number" pattern="###,###.00"
						value="${product.price}" var="balance" /> ${balance}</td>
			</tr>
			<tr>
				<td>Seller's Name</td>
				<td>&#160;:&#160;</td>
				<td>${fn:escapeXml(product.ownerName)}</td>
			</tr>			
			<tr>
				<td>Seller's Comment</td>
				<td>&#160;:&#160;</td>
				<td>${fn:escapeXml(product.comment)}</td>
			</tr>
			<tr>
				<td>Posting Date</td>
				<td>&#160;:&#160;</td>
				<td><fmt:formatDate type="date" value="${product.createdDate}"/></td>
			</tr>
		</table>

		<h4>Buyer's Comment and Ratings</h4>
		<c:choose>
			<c:when test="${not empty feedbackList}">
				<table>
					<tr class="headerTable">
						<td>&#160;</td>
						<td>Buyer's Name</td>
						<td>Buyer's Comment</td>
						<td>Buyer's Rating</td>
						<td>Submitted On</td>
					</tr>
					<c:forEach var="feedback" items="${feedbackList}" varStatus="rowCounter">
						 <c:choose>
							<c:when test="${rowCounter.count % 2 == 0}">
								<c:set var="rowStyle" scope="page" value="odd" />
							</c:when>
							<c:otherwise>
								<c:set var="rowStyle" scope="page" value="even" />
							</c:otherwise>
						</c:choose>
						<tr class="{rowStyle}">
							<td>${rowCounter.count}</td>
							<td>${fn:escapeXml(feedback.commentorName)}</td>
							<td>${fn:escapeXml(feedback.comment)}</td>
							<td align="center">${fn:escapeXml(feedback.rating)}</td>
							<td><fmt:formatDate type="date" value="${feedback.createdDate}"/></td>
						</tr>
					</c:forEach>
				</table>
			</c:when>
			<c:otherwise>
				<p>No Comment and Rating found.</p>
			</c:otherwise>			
		</c:choose>

	</div>

</body>
	</html>
</jsp:root>